/// id : "https://ch.amwaynet.com.cn/content/china/accl/ch/business-opportunity/support/2020/0106008.html"
/// title : "“安利头条”上线啦 使用中遇到的问题戳这里！"
/// description : "安利头条常见问题汇总。"
/// thumbnail : "https://ch.amwaynet.com.cn/content/dam/china/accl/content_hub/business-opportunity/support/2020/0106008/0.jpg"
/// publishDate : "2020-01-05T16:00:00Z"
/// url : "https://ch.amwaynet.com.cn/content/china/accl/ch/business-opportunity/support/2020/0106008.html"
/// allowShare : true
/// views : 0
/// tags : ["热点讨论","安利头条"]

class OfficialCircleData {
  String _id;
  String _content;
  String _title;
  String _description;
  String _thumbnail;
  String _publishDate;
  String _url;
  bool _allowShare;
  int _views;
  List<String> _tags;
  List<String> _images;
  List<Product> _products;

  String get id => _id;

  String get title => _title;

  String get content => _content;

  String get description => _description;

  String get thumbnail => _thumbnail;

  String get publishDate => _publishDate;

  String get url => _url;

  bool get allowShare => _allowShare;

  int get views => _views;

  List<String> get tags => _tags;

  List<String> get images => _images;

  List<Product> get products => _products;

  OfficialCircleData(
      {String id,
      String title,
      String content,
      String description,
      String thumbnail,
      String publishDate,
      String url,
      bool allowShare,
      int views,
      List<String> tags,
      List<Product> products}) {
    _id = id;
    _title = title;
    _content = content;
    _description = description;
    _thumbnail = thumbnail;
    _publishDate = publishDate;
    _url = url;
    _allowShare = allowShare;
    _views = views;
    _tags = tags;
    _images = images;
    _products = products;
  }

  OfficialCircleData.fromJson(dynamic json) {
    _id = json["id"];
    _title = json["title"];
    _content = json["content"];
    _description = json["description"];
    _thumbnail = json["thumbnail"];
    _publishDate = json["publishDate"];
    _url = json["url"];
    _allowShare = json["allowShare"];
    _views = json["views"];
    _tags = json["tags"] != null ? json["tags"].cast<String>() : [];
    _images = json["images"] != null ? json["images"].cast<String>() : [];
    if (json["products"] != null) {
      _products = [];
      json["products"].forEach((v) {
        _products.add(Product.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["id"] = _id;
    map["title"] = _title;
    map["content"] = _content;
    map["description"] = _description;
    map["thumbnail"] = _thumbnail;
    map["publishDate"] = _publishDate;
    map["url"] = _url;
    map["allowShare"] = _allowShare;
    map["views"] = _views;
    map["tags"] = _tags;
    map["images"] = _images;
    if (_products != null) {
      map["products"] = _products.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class Product {
  String _id;
  String _count;

  String get count => _count;

  String get id => _id;

  Product({String id, String count}) {
    _id = id;
    _count = count;
  }

  Product.fromJson(dynamic json) {
    _id = json["id"].toString();
    _count = json["count"].toString();
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["id"] = _id;
    map["count"] = _count;
    return map;
  }
}
